package cn.base;

public class ThreadCount implements Runnable {

    public static int count = 100;

    @Override
    public void run() {
        Class clazz = getClass();
        while (true) {
            // 输入非公平锁
            if (count >= 1) {
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (clazz) {
                    count--;
                    System.out.println(Thread.currentThread().getName() + "执行完成" + count);
                }
            } else {
                break;
            }
        }
    }
}
